<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
	<div region="center" style="padding: 0px; border: 0px">
		<t:datagrid name="wxMassBillList" checkbox="true" fitColumns="false"
			title="微信群发消息" actionUrl="wxMassBillController.do?datagrid"
			idField="id" fit="true" queryMode="group">
			<t:dgCol title="主键" field="id" hidden="true" queryMode="single"
				width="120"></t:dgCol>
			<t:dgCol title="创建人名称" field="createName" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="创建人登录名称" field="createBy" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="创建日期" field="createDate" formatter="yyyy-MM-dd"
				hidden="true" queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="更新人名称" field="updateName" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="更新人登录名称" field="updateBy" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="更新日期" field="updateDate" formatter="yyyy-MM-dd"
				hidden="true" queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="所属部门" field="sysOrgCode" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="所属公司" field="sysCompanyCode" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="单号" field="billNumber" queryMode="single" width="100"></t:dgCol>
			<t:dgCol title="消息类型" field="msgType" dictionary="massmsgtype"
				queryMode="single" width="70"></t:dgCol>
			<t:dgCol title="文本内容" field="textMsg" queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="模板标识" field="templateId" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="模板名称" field="templateName" queryMode="single"
				width="120"></t:dgCol>
			<t:dgCol title="模板媒体标识" field="mediaId" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="全部发送" field="isToAll" hidden="true"
				queryMode="single" dictionary="yesorno" width="120"></t:dgCol>
			<t:dgCol title="转载继续发送" field="sendIgnoreReprint" hidden="true"
				queryMode="single" dictionary="yesorno" width="120"></t:dgCol>
			<t:dgCol title="卡券标识" field="cardId" hidden="true" queryMode="single"
				width="120"></t:dgCol>
			<t:dgCol title="卡券名称" field="cardName" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="消息标识" field="msgId" hidden="true" queryMode="single"
				width="120"></t:dgCol>
			<t:dgCol title="消息的数据ID" field="msgDataId" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="发送状态" field="sendStatus" queryMode="single"
				width="80"></t:dgCol>
			<t:dgCol title="失败信息" field="sendErrMsg" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="粉丝数" field="totalCount" hidden="true"
				queryMode="single" width="100"></t:dgCol>
			<t:dgCol title="过滤后粉丝数" field="filterCount" hidden="true"
				queryMode="single" width="100"></t:dgCol>
			<t:dgCol title="成功发送数" field="sentCount" queryMode="single"
				width="100"></t:dgCol>
			<t:dgCol title="失败数量" field="errorCount" queryMode="single"
				width="100"></t:dgCol>
			<t:dgCol title="整体校验结果" field="checkState" hidden="true"
				queryMode="single" width="120"></t:dgCol>
			<t:dgCol title="备注" field="remark" hidden="true" queryMode="single"
				width="120"></t:dgCol>
			<t:dgCol title="操作" field="opt" width="150"></t:dgCol>
			<t:dgDelOpt title="删除" url="wxMassBillController.do?doDel&id={id}" />
			<t:dgFunOpt title="预览" funname="preview(id)"></t:dgFunOpt>
			<t:dgFunOpt title="发送" funname="send(id)"></t:dgFunOpt>
			<t:dgToolBar title="录入" icon="icon-add"
				url="wxMassBillController.do?goAdd" funname="add" width="100%"
				height="100%"></t:dgToolBar>
			<t:dgToolBar title="编辑" icon="icon-edit"
				url="wxMassBillController.do?goUpdate" funname="update" width="100%"
				height="100%"></t:dgToolBar>
			<t:dgToolBar title="批量删除" icon="icon-remove"
				url="wxMassBillController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>
			<t:dgToolBar title="查看" icon="icon-search"
				url="wxMassBillController.do?goUpdate" funname="detail" width="100%"
				height="100%"></t:dgToolBar>
			<t:dgToolBar title="导入" icon="icon-put" funname="ImportXls"></t:dgToolBar>
			<t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
			<t:dgToolBar title="模板下载" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>
		</t:datagrid>
	</div>
</div>
<script
	src="webpage/com/gomore/wechat/module/message/mass/wxMassBillList.js"></script>
<script type="text/javascript">
  $(document).ready(
      function() {
        //给时间控件加上样式
        $("#wxMassBillListtb").find("input[name='createDate']").attr("class",
            "Wdate").click(function() {
          WdatePicker({
            dateFmt : 'yyyy-MM-dd'
          });
        });
        $("#wxMassBillListtb").find("input[name='updateDate']").attr("class",
            "Wdate").click(function() {
          WdatePicker({
            dateFmt : 'yyyy-MM-dd'
          });
        });
      });

  function preview(id) {
    $.messager.prompt("确认预览", "请输入要预览的微信号...", function(data) {
      if (data) {
        doPreview(id, data);
      }
    });
  }

  function doPreview(id, wxuser) {
    $.ajax({
      url : "wxMassBillController.do?preview",
      type : 'post',
      data : {
        'id' : id,
        'userName' : wxuser
      },
      cache : false,
      dataType : 'json',
      success : function(data) {
        if (!data.success) {
          tip('预览失败: ' + data.msg);
        } else {
          tip(data.msg);
          reloadTable();
          $("#" + gname).datagrid('unselectAll');
        }
      }
    });
  }

  function send(id) {
    $.messager.confirm("确认操作", '确认要群发消息吗？', function(r) {
      if (r) {
        doSend(id);
      }
    });
  }

  function doSend(id) {
    $.ajax({
      url : "wxMassBillController.do?send",
      type : 'post',
      data : {
        'id' : id
      },
      cache : false,
      dataType : 'json',
      success : function(data) {
        if (!data.success) {
          tip('发送失败: ' + data.msg);
        } else {
          tip(data.msg);
          reloadTable();
          $("#" + gname).datagrid('unselectAll');
        }
      }
    });
  }

  //导入
  function ImportXls() {
    openuploadwin('Excel导入', 'wxMassBillController.do?upload', "wxMassBillList");
  }

  //导出
  function ExportXls() {
    JeecgExcelExport("wxMassBillController.do?exportXls", "wxMassBillList");
  }

  //模板下载
  function ExportXlsByT() {
    JeecgExcelExport("wxMassBillController.do?exportXlsByT", "wxMassBillList");
  }
</script>